package org.ant.MyCalculate;

import java.util.HashMap;

import android.widget.Button;
import android.widget.TextView;

public class EquationTool {
	private Button button;
	private TextView textView;
	private Double firstNumber;
	private Double secondNumber;
	private String operation;
	private Boolean flag;
	
	EquationTool(Button button, TextView textView ,Double firstNumber, Double secondNumber ,String operation ,Boolean flag){
		this.button = button;
		this.textView = textView;
		this.firstNumber = firstNumber;
		this.secondNumber = secondNumber;
		this.operation = operation;
		this.flag = flag;
	}
	
	HashMap<String, Object> dealEquation(){
		return calculteResult(button,textView);
	}
	
	private HashMap<String, Object> calculteResult(Button buttonEqu,TextView textView){
		Double result;
		HashMap<String,Object> hashMap = new HashMap<String, Object>();
		OperationTool operationTool = new OperationTool (firstNumber ,secondNumber ,operation ,textView); 
		result = operationTool.dealOperation();
		firstNumber = result;
		operation = "";
		flag = false;
//		textView.setText(textView.getText().toString() + button.getText());
		hashMap.put("textView", textView);
		hashMap.put("flag", flag);
		hashMap.put("operation", operation);
		hashMap.put("firstNumber", firstNumber);
		hashMap.put("secondNumber", null);
		return hashMap;
	}
}
